<?php
namespace App\Api\V1\Models;

use Illuminate\Database\Eloquent\Model;

class Promotion extends Model
{
    protected $table = 'promotion';
    public $timestamps = false;
    public function addPromotionItem($res)
    {
        $data=[
            'name'=>'端午订单促销',
            'begin_time'=>'2018-05-26 15:20:23',
            'end_time'=>'2018-06-26 15:20:23',
            'status'=>'1',

        ];
        $this->name = $data['name'];
        $this->begin_time = $data['begin_time'];
        $this->end_time = $data['end_time'];
        $this->status= $data['status'];
        if ($this->save()) {
            return $this->toArray();
        }
        return false;
    }
    public function setPromotionItem()
    {
        $data=[
            'name'=>'端午订单促销',
            'begin_time'=>'2018-05-26 15:20:23',
            'end_time'=>'2018-06-26 15:20:23',
            'status'=>'1',

        ];
        $res = promotion::where('promotion_id',23)->update($data);
        return false;
    }
    public function getPromotionItem()
    {
        $df=promotion::where('promotion_id',40)->first()->toarray();

        return $df;
    }
    public function delPromotionList()
    {
        $tt=promotion::where('promotion_id', 42)->delete();
        if($tt){
            return true;
        }
    }
}
